package main.java.com.service.impl;

import main.java.com.dao.DishDao;
import main.java.com.dao.impl.DishDaoImpl;
import main.java.com.entity.Dish;
import main.java.com.service.DishService;

import java.util.List;

public class DishServiceImpl implements DishService {
    private DishDao dishDAO = new DishDaoImpl();

    @Override
    public List<Dish> getAllDishes(int page, int pageSize, String keyword, Integer status) {
        int offset = (page - 1) * pageSize;
        return dishDAO.getAllDishes(offset, pageSize, keyword, status);
    }

    @Override
    public List<Dish> getAllDishes2() {
        return dishDAO.getAllDishes2();
    }

    @Override
    public Dish getDishById(Long id) {
        return dishDAO.getDishById(id);
    }

    @Override
    public void addDish(Dish dish) {
        dishDAO.addDish(dish);
    }

    @Override
    public boolean  updateDish(Dish dish) {
      return   dishDAO.updateDish(dish);
    }

    @Override
    public int deleteDish(Long id) {

        return dishDAO.deleteDish(id);
    }

    @Override
    public void updateDishStatus(Long id, Integer status) {
        dishDAO.updateDishStatus(id, status);
    }

    @Override
    public int getDishCount(String keyword, Integer status) {
        return dishDAO.getDishCount(keyword, status);
    }

    @Override
    public int batchDeleteDishes(List<Long> ids) {
        return dishDAO.batchDeleteDishes(ids);
    }

    @Override
    public int batchUpdateStatus(List<Long> ids, int status) {
        return dishDAO.batchUpdateStatus(ids,status);
    }


    @Override
    public List<Dish> getDishesByCategory(String categoryName) {
        return dishDAO.getDishesByCategory(categoryName);
    }

}
